home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / VB--_HTML 198205202001.psc / VBHelpCompiler / Test Project / UserControl1.ctl < prev   
Encoding:
Text File  |  2001-05-06  |  6.5 KB  |  200 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.UserControl Client 
  4.    ClientHeight    =   3600
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4800
  8.    PropertyPages   =   "UserControl1.ctx":0000
  9.    ScaleHeight     =   240
  10.    ScaleMode       =   3  'Pixel
  11.    ScaleWidth      =   320
  12.    ToolboxBitmap   =   "UserControl1.ctx":000F
  13.    Begin MSWinsockLib.Winsock Sock 
  14.       Left            =   2160
  15.       Top             =   1560
  16.       _ExtentX        =   741
  17.       _ExtentY        =   741
  18.       _Version        =   393216
  19.    End
  20.    Begin VB.Image Image1 
  21.       Appearance      =   0  'Flat
  22.       BorderStyle     =   1  'Fixed Single
  23.       Height          =   390
  24.       Left            =   0
  25.       Picture         =   "UserControl1.ctx":0321
  26.       Top             =   0
  27.       Width           =   390
  28.    End
  29. End
  30. Attribute VB_Name = "Client"
  31. Attribute VB_GlobalNameSpace = False
  32. Attribute VB_Creatable = True
  33. Attribute VB_PredeclaredId = False
  34. Attribute VB_Exposed = True
  35. Attribute VB_Ext_KEY = "PropPageWizardRun" ,"Yes"
  36. Public vConnectionString As String
  37. Attribute vConnectionString.VB_VarProcData = "ppClient"
  38. 'Event Declarations:
  39. Event DataArrival(ByVal Data As String)
  40. Event Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  41. Event SendComplete()
  42. Event SendProgress(ByVal Percent As Long)
  43. Event Disconnected()
  44.  
  45. Public Sub About()
  46. frmAbout.Show
  47. frmAbout.InitAboutBox True
  48. End Sub
  49.  
  50. Private Sub Sock_Close()
  51. RaiseEvent Disconnected
  52. End Sub
  53.  
  54. Private Sub UserControl_Initialize()
  55. UserControl_Resize
  56. End Sub
  57.  
  58. Private Sub UserControl_Paint()
  59. UserControl_Resize
  60. End Sub
  61.  
  62. Private Sub UserControl_Resize()
  63. If UserControl.Width <> 385 Then UserControl.Width = 385
  64. If UserControl.Height <> 385 Then UserControl.Height = 385
  65. End Sub
  66.  
  67. Public Sub Bind(Optional ByVal LocalPort As Variant, Optional ByVal LocalIP As Variant)
  68. Attribute Bind.VB_Description = "Binds socket to specific port and adapter"
  69.     Sock.Bind LocalPort, LocalIP
  70. End Sub
  71.  
  72. Public Sub Disconnect()
  73.     Sock.Close
  74. End Sub
  75.  
  76. Public Sub Connect()
  77. Attribute Connect.VB_Description = "Connect to the remote computer"
  78.     Sock.Connect
  79. End Sub
  80.  
  81. Private Sub Sock_DataArrival(ByVal bytesTotal As Long)
  82.     Dim a As String
  83.     Sock.GetData a, vbString, bytesTotal
  84.     If a = "Send_Connection_String" Then
  85.     Sock.SendData ConnectionString
  86.     Else
  87.     RaiseEvent DataArrival(a)
  88.     End If
  89. End Sub
  90.  
  91. Private Sub Sock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  92.     RaiseEvent Error(Number, Description, Scode, Source, HelpFile, HelpContext, CancelDisplay)
  93. End Sub
  94.  
  95. Public Property Get LocalHostName() As String
  96. Attribute LocalHostName.VB_Description = "Returns the local machine name"
  97.     LocalHostName = Sock.LocalHostName
  98. End Property
  99.  
  100. Public Property Get LocalIP() As String
  101. Attribute LocalIP.VB_Description = "Returns the local machine IP address"
  102.     LocalIP = Sock.LocalIP
  103. End Property
  104.  
  105. Public Property Get LocalPort() As Long
  106.     LocalPort = Sock.LocalPort
  107. End Property
  108.  
  109. Public Property Let LocalPort(ByVal New_LocalPort As Long)
  110.     Sock.LocalPort = New_LocalPort
  111.     PropertyChanged "LocalPort"
  112. End Property
  113.  
  114. Public Property Get ConnectionString() As String
  115.     ConnectionString = vConnectionString
  116. End Property
  117.  
  118. Public Property Let ConnectionString(ByVal New_ConnectioString As String)
  119.     vConnectionString = New_ConnectioString
  120.     PropertyChanged "ConnectionString"
  121. End Property
  122.  
  123. Public Property Get Protocol() As ProtocolConstants
  124. Attribute Protocol.VB_Description = "Returns/Sets the socket protocol"
  125.     Protocol = Sock.Protocol
  126. End Property
  127.  
  128. Public Property Let Protocol(ByVal New_Protocol As ProtocolConstants)
  129.     Sock.Protocol = New_Protocol
  130.     PropertyChanged "Protocol"
  131. End Property
  132.  
  133. Public Property Get RemoteHost() As String
  134. Attribute RemoteHost.VB_Description = "Returns/Sets the name used to identify the remote computer"
  135. Attribute RemoteHost.VB_ProcData.VB_Invoke_Property = "ppClient"
  136.     RemoteHost = Sock.RemoteHost
  137. End Property
  138.  
  139. Public Property Let RemoteHost(ByVal New_RemoteHost As String)
  140.     Sock.RemoteHost = New_RemoteHost
  141.     PropertyChanged "RemoteHost"
  142. End Property
  143.  
  144. Public Property Get RemoteHostIP() As String
  145. Attribute RemoteHostIP.VB_Description = "Returns the remote host IP address"
  146.     RemoteHostIP = Sock.RemoteHostIP
  147. End Property
  148.  
  149. Public Property Get RemotePort() As Long
  150. Attribute RemotePort.VB_Description = "Returns/Sets the port to be connected to on the remote computer"
  151. Attribute RemotePort.VB_ProcData.VB_Invoke_Property = "ppClient"
  152.     RemotePort = Sock.RemotePort
  153. End Property
  154.  
  155. Public Property Let RemotePort(ByVal New_RemotePort As Long)
  156.     Sock.RemotePort = New_RemotePort
  157.     PropertyChanged "RemotePort"
  158. End Property
  159.  
  160. Private Sub Sock_SendComplete()
  161.     RaiseEvent SendComplete
  162. End Sub
  163.  
  164. Public Sub SendData(ByVal Data As Variant)
  165. Attribute SendData.VB_Description = "Send data to remote computer"
  166.     Sock.SendData Data
  167. End Sub
  168.  
  169. Private Sub Sock_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
  170. Percent = (bytesSent / bytesRemaining) * 100
  171.     RaiseEvent SendProgress(Percent)
  172. End Sub
  173.  
  174. Public Property Get SocketHandle() As Long
  175. Attribute SocketHandle.VB_Description = "Returns the socket handle"
  176.     SocketHandle = Sock.SocketHandle
  177. End Property
  178.  
  179. Public Property Get State() As Integer
  180. Attribute State.VB_Description = "Returns the state of the socket connection"
  181.     State = Sock.State
  182. End Property
  183.  
  184. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  185.     vConnectionString = PropBag.ReadProperty("ConnectionString", "")
  186.     Sock.LocalPort = PropBag.ReadProperty("LocalPort", 0)
  187.     Sock.Protocol = PropBag.ReadProperty("Protocol", 0)
  188.     Sock.RemoteHost = PropBag.ReadProperty("RemoteHost", "")
  189.     Sock.RemotePort = PropBag.ReadProperty("RemotePort", 0)
  190. End Sub
  191.  
  192. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  193.     Call PropBag.WriteProperty("ConnectionString", vConnectionString, "")
  194.     Call PropBag.WriteProperty("LocalPort", Sock.LocalPort, 0)
  195.     Call PropBag.WriteProperty("Protocol", Sock.Protocol, 0)
  196.     Call PropBag.WriteProperty("RemoteHost", Sock.RemoteHost, "")
  197.     Call PropBag.WriteProperty("RemotePort", Sock.RemotePort, 0)
  198. End Sub
  199.  
  200.